package com.studentsys.service;

import com.studentsys.bean.Student;
import com.studentsys.dao.StudentDao;
import com.studentsys.utils.PageUtils;

import java.util.List;

public class StudentService {
    private StudentDao sd = new StudentDao();
    public int insert(Student stu){
        return sd.insert(stu);
    }
    public List<Student> selectAll(){
        return sd.selectAll();
    }
    public Student selectOne(int sid){
        return sd.selectOne(sid);
    }
    public int updateStudent(Student stu){
        return sd.updateStudent(stu);
    }
    public int deleteStudent(int sid){
        return sd.deleteStudent(sid);
    }


    //邮箱唯一性验证
    public boolean checkEmail(String email) {
        Student stu = sd.checkEmail(email);
        if (stu!=null){
            return true;
        }else{
            return false;
        }
    }


    public boolean checkSname(String sname) {
        Student stu = sd.checkSname(sname);
        if (stu!=null){
            return true;
        }else{
            return false;
        }
    }

    public boolean checkAge(String age) {
        Student stu = sd.checkAge(age);
        if (stu!=null){
            return true;
        }else{
            return false;
        }
    }
    //分页查询
    public List<Student> findByPage(PageUtils page){
        return sd.findByPage(page);
    }
    //查询总条数
    public int getTotalCount(){
        return sd.getTotalCount();
    }
}
